<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>lesson 22</title>
  <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
  <div id="root"></div>
</body>
<script>
  //ref获取dom节点或组件
  const app = Vue.createApp({
    mounted() {
      val = this.$refs.content
      console.log(val);
      demo = this.$refs.demo.sayHi()
      console.log(demo);
    },
    template: `
   <div>
    <p ref="content">一段文件</p>
    <demo ref="demo"></demo>
    </div>
    `
  })
  app.component('demo', {
    methods: {
      sayHi() {
        alert('hi')
      }
    },
    template: `<div>demo组件</div>`
  })

  const vm = app.mount('#root');
</script>

</html>